package com.test.daily.leetcode.y2022.m05.day0518.v02;

import java.util.PriorityQueue;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/5/18 上午 10:04
 * @version: 1.0
 */
public class Solution {
    public static void main(String[] args) {
        printMiddle(200, 1000);
        System.out.println(new Solution().findKthNumber(3,3,5));
    }
    public static void printMiddle(int left, int right){
        while(left < right){
            int middle = left + ((right-left)>>1);
            System.out.println("left:" + left+",right:"+right +",middle:"+middle);
            left = middle+1;
        }
    }
    public int findKthNumber(int m, int n, int k) {
        int left= 1, right = m*n;
        while(left < right){
            int middle = left + ((right - left)>>1);
            int count = middle / n * n;
            for(int i = middle/n + 1; i <=m; i++){
                count += middle/i;
            }
            if(k > count){
                left = middle + 1;
            }else {
                right = middle;
            }
        }
        return left;
    }
}
